package com.ep.demo.service;

import java.io.File;
import java.io.FileOutputStream;
import java.util.List;

import javax.annotation.Resource;

import org.jfree.chart.ChartFactory;
import org.jfree.data.category.CategoryDataset;
import org.junit.Test;
import org.springframework.stereotype.Service;

import com.ep.demo.bo.IBookBO;
import com.ep.demo.entity.Book;
import com.ep.entity.Paper;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfDiv;
import com.itextpdf.text.pdf.PdfWriter;
@Service("bookService")
public class BookService implements IBookService{
	@Resource(name="bookBO")
	private IBookBO bo;
	public void saveBook(Book book) {
//		book.setId(UUID.randomUUID().toString());
//		book.setName("dddd"); 
//		book.setOldname("dddddffffff");
		bo.saveBook(book);
	}
	public IBookBO getBo() {
		return bo;
	}
	public void setBo(IBookBO bo) {
		this.bo = bo;
	}
	@Override
	public void savePaperList(List<Paper> list) {
		if(null!=list&&list.size()>0){
			for(Paper  paper:list){
				bo.savePaper(paper);
			}
		}	
	}
	public void getJfreeChart(){
	}
	/**
	 * 导出pdf helloworld
	 */
	@Test
	public void getPdf(){
		try {
			//Step 1—Create a Document.  
			Document document=new Document();
			//Step 2—Get a PdfWriter instance.  
			String path="E://SLSLSL.PDF";
			PdfWriter.getInstance(document, new FileOutputStream(new File(path)));
			//Step 3—Open the Document.  
			document.open();
			//Step 4—Add content.  
			document.add(new Paragraph("hehehehehehehehehhe"));
			//Step 5—Close the Document.
			document.close();
		} catch (Exception e) {
			e.printStackTrace();
		}  
	}
}
